package jhunter.rt.conf.ext;

import jhunter.conf.actions.vo.Actions;
import jhunter.rt.conf.Node;
import jhunter.rt.conf.Reloadable;

public class ActionsExt implements Reloadable {

	private Actions actions;

	private Node actionsNode;

	public ActionsExt(Actions actions, Node actionsNode) {
		super();
		this.actions = actions;
		this.actionsNode = actionsNode;
	}

	public Actions getActions() {
		return actions;
	}

	public void setActions(Actions actions) {
		this.actions = actions;
	}

	public Node getActionsNode() {
		return actionsNode;
	}

	public void setActionsNode(Node actionsNode) {
		this.actionsNode = actionsNode;
	}

	public ModuleExt getModuleExt() {
		return (ModuleExt) actionsNode.getParent().getObject();
	}

	public ActionExt getAction(String actionName) {
		for (Node node : actionsNode.getChildren()) {
			ActionExt action = (ActionExt) node.getObject();
			if (action.getAction().getName().equals(actionName)) {
				return action;
			}
		}
		return null;
	}

	@Override
	public void unload() {
		// TODO Auto-generated method stub

	}

	@Override
	public void afterLoad() {
		// TODO Auto-generated method stub

	}

	@Override
	public void init() {
		afterLoad();
	}

}
